# -*- coding:utf-8 -*-
the_day = '20210820'  #截至计算时间
import sys
from ntpath import join
import time
import tushare as ts
import datetime
from SNetwork.StockSQL import StockSQL
from SChart.StockChart import StockChart
from SData.StockHtmlTool import StockHtmlTool
from SChart.StockMT import StockMT
from SChart.StockAccount import StockAccount

from STool.StockTT import *
from STool.StockTool import StockTool
from SDaily.StockYearHigh import StockYearHigh
from SDaily.StockSingle import StockSingle



class StockDataManager:
    def __init__(self,sql):
            self.mysql = sql
            self.current_trade_date = StockSingle().trade_date_now #trade_date:20220819


    def dealBKDataToSql(self,stock_bk_rps5_dic):
        bk_dic_sql={}
        bk_dic_sql['trade_date']= self.current_trade_date
        bk_array=[]
        for key,value in stock_bk_rps5_dic.items():
            aa = {
                "industry":key,
                "bankuai_mt":value
                }
            bk_array.append(aa)
        bk_dic_sql['bk_data']=bk_array
        
        
        bk_local_info = self.mysql.stock_bankuai_mt.find_one({ "trade_date": self.current_trade_date })

        if bk_local_info != None:#本地数据库存在code
            #更新本地 交易K线，上市日期、持仓数据
            newvalues = { "$set": bk_dic_sql}  
            self.mysql.stock_bankuai_mt.update_one({ "trade_date": self.current_trade_date }, newvalues)
        else:
            self.mysql.stock_bankuai_mt.insert_one(bk_dic_sql)    
    
    